home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / rettig.arc / TRSOURCE.EXE / DEC.C < prev    next >
C/C++ Source or Header  |  1990-10-22  |  675b  |  32 lines

  1. /*********
  2. *
  3. * DEC.C
  4. *
  5. * by Ralph Davis
  6. *
  7. * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  8. *
  9. *  Syntax:  DEC( <expC> )
  10. *  Return:  Decimal equivalent of hexadecimal string <expC>
  11. *********/
  12.  
  13. #include "trlib.h"
  14.  
  15. TRTYPE dec()
  16. {
  17.     char *s;
  18.  
  19.     if ( PCOUNT == 1 && ISCHAR(1) )
  20.     {
  21.        s = _parc(1);
  22.        if (_tr_strlen(s) <= 4)   /* If four characters in string,
  23.                                       convert to integer */
  24.           _retnd((double) _tr_htoi(s));
  25.  
  26.        else                      /* Otherwise, convert to long */
  27.           _retnd((double) _tr_htol(s));
  28.     }
  29.     else
  30.        _retnd( (double)ERROR );
  31. }
  32.